$webwork.htmlEncode($page.space.name) : Freemarker templates
This page last changed on Aug 03, 2007 by jdeolive.
This tutorial will introduce you to a more in depth view of what FreeMarker templates are and how you can use the data provided to templates by GeoServer. FreemarkerFreemarker is a simple yet powerful template engine that GeoServer uses whenever developer allowed user customization of outputs. In particular, at the time of writing it's used to allow customization of GetFeatureInfo, GeoRSS and KML outputs. Freemarker allows for simple variable expansions, as in ${myVarName}, expansion of nested properties, such as in ${feature.myAtt.value}, up to little programs using loops, ifs and variables. Template lookupGeoserver looks up templates in three different places, allowing you for various level of customization. Given a templated output, a template name (template.ftl) and a feature type (myFeatureType), Geoserver will perform the following lookups:
Each templated output format tutorial should provide you with the template names, and state whether the templates can be type specific, or not. Common Data ModelsFreemarker calls "data model" the set of data provided to the template. Each output format used by Geoserver will inject a different data model according to the informations it's managing, yet there are three very common elements that appear in almost each template, Feature, FeatureType and FeatureCollection. Here we provide a data model of each. The data model is a sort of a tree, where each element has a name and a type. Besides basic types, we'll use:
Here are the three data models (as you can see there are redundancies, in particular in attributes, we chose this approach to make template building easier):
|
![]() |
Document generated by Confluence on Jan 16, 2008 23:27 |